home *** CD-ROM | disk | FTP | other *** search
/ Enigma Amiga Life 109 / EnigmaAmiga109CD.iso / dalla rivista / news / burnit_demo / burnit_addon.lha / BurnIT_CDCover.rexx next >
OS/2 REXX Batch file  |  1999-11-09  |  11KB  |  534 lines

  1. /* 
  2.    $VER: BurnIT_CDCover.rexx 1.0 (20.10.99)
  3.    Copyright 1999 Michael Siegel
  4.  
  5.    Description:
  6.    Convert BurnIT CDDB ReadDiscIDs to CD covers plus inlays
  7.  
  8.    **** USE ENTIRELY AT YOUR OWN RISK ! ****
  9. */
  10.  
  11. PARSE ARG infilename
  12. OPTIONS RESULTS
  13.  
  14. /* Constants */
  15.  
  16. cover_width        = 120.65
  17. cover_heigth       = 120.65
  18. cover_space        = 2
  19.  
  20. inlay_side_width   = 7
  21. inlay_side_space   = 1
  22. inlay_side_top     = 5
  23. inlay_side_length  = 108
  24.  
  25. inlay_middle_width = 137
  26. inlay_heigth       = 118
  27. inlay_middle_space = 5
  28.  
  29. cover_x1           = 12.7
  30. cover_y1           = 25.4
  31. cover_x2           = cover_x1 + cover_width
  32. cover_y2           = cover_y1 + cover_heigth
  33.  
  34. inlay_left_x1      = cover_x1
  35. inlay_left_y1      = cover_y1 + cover_heigth
  36. inlay_left_x2      = inlay_left_x1 + inlay_side_width
  37. inlay_left_y2      = inlay_left_y1 + inlay_heigth
  38.  
  39. inlay_middle_x1    = inlay_left_x2
  40. inlay_middle_y1    = inlay_left_y1
  41. inlay_middle_x2    = inlay_middle_x1 + inlay_middle_width
  42. inlay_middle_y2    = inlay_left_y2
  43.  
  44. inlay_right_x1     = inlay_middle_x2
  45. inlay_right_y1     = inlay_middle_y1
  46. inlay_right_x2     = inlay_right_x1 + inlay_side_width
  47. inlay_right_y2     = inlay_middle_y2
  48.  
  49. /*******************************************************************/
  50.  
  51. tno_start_x = 32.7
  52. tno_start_y = 161.4
  53.  
  54. /*******************************************************************/
  55.  
  56. /* Init */
  57.  
  58. tno         = 1
  59. max_len     = 0
  60.  
  61. /*
  62. infilename='dh3:cddb.txt'
  63. */
  64.  
  65. /* Test Pagestream */
  66.  
  67. IF ~SHOW('Ports', 'PAGESTREAM') THEN
  68. DO
  69.     ADDRESS COMMAND    'RUN Pagestream3:Pagestream3'
  70.     ADDRESS COMMAND 'SYS:RexxC/WaitForPort Pagestream'
  71. END
  72.  
  73. IF ~SHOW('Ports', 'PAGESTREAM') THEN
  74.     RETURN 1
  75.  
  76. ADDRESS 'PAGESTREAM'
  77.  
  78. /* Init CDDB Data */
  79.  
  80. IF ~OPEN(infile, infilename, 'R') THEN
  81.     RETURN 9
  82.  
  83. composer = READLN(infile)
  84. titel    = READLN(infile)
  85. titel    = STRIP(DELSTR(titel, LASTPOS('[', titel)))
  86. titel    = replace_text(titel)
  87.  
  88. /* Count Lines */
  89.  
  90. DO UNTIL EOF(infile)
  91.  
  92.     titel_line    = READLN(infile)
  93.  
  94.     IF titel_line = "" THEN
  95.         BREAK
  96.  
  97.     titel_line    = STRIP(titel_line)
  98.     titel_time    = STRIP(SUBSTR(titel_line, LASTPOS('[', titel_line)))
  99.     titel_line    = STRIP(DELSTR(titel_line, LASTPOS('[', titel_line)))
  100.  
  101.     len           = LENGTH(titel_line)
  102.  
  103.     IF len > max_len THEN DO
  104.         max_len = len
  105.     END
  106.  
  107.     tno_titel.tno = replace_quot(titel_line)
  108.     tno_time.tno  = titel_time
  109.     tno           = tno + 1
  110. END
  111.  
  112. anzahl_tno = tno - 1
  113. tno_heigth = 100 / anzahl_tno
  114.  
  115. IF tno_heigth > 10 THEN
  116.     tno_heigth = 10
  117.  
  118. /* Init Pagestream */
  119.  
  120. 'NEWDOCUMENT "BurnIT CDCover"'
  121. 'NEWMASTERPAGE "Default Master Page" 210mm 297mm SINGLE PORTRAIT'
  122. 'SETDIMENSIONS 210mm 297mm SINGLE PORTRAIT'
  123. 'SETMARGINGUIDES 12.7mm 12.7mm 25.4mm 25.4mm'
  124. 'SETCOLUMNGUIDES 1 1mm'
  125. 'SETDOCUMENTSTATUS UNCHANGED'
  126. 'OPENWINDOW "View 1" PAGE 1'
  127.  
  128. 'OPENBUSYREQUESTER MESSAGE "Preparing CDCover..." THERMOMETER ENABLED ABORT ENABLED TOTAL 100 CURRENT 0'
  129.  
  130. busyreq = RESULT
  131.  
  132. /*
  133. 'FILLED OFF OBJECT'
  134. 'SETFILL BASIC FILL OBJECT'
  135. 'SETFPATTERN NONE FILL OBJECT'
  136. 'SETCOLORCOUNT 1 FILL OBJECT'
  137. 'SETCOLORSTYLE Black COLORNUMBER 0 FILL OBJECT'
  138. 'SETCOLORTINT 100% COLORNUMBER 0 FILL OBJECT'
  139. 'SETSCREEN 4 DEFAULT DEFAULT DEFAULT DEFAULT DEFAULT DEFAULT DEFAULT DEFAULT DEFAULT DEFAULT DEFAULT DEFAULT OBJECT'
  140. 'STROKED OFF OBJECT'
  141. 'SETSTROKECOUNT 1 OBJECT'
  142. 'SETSTROKE SOLID STROKENUMBER 0 OBJECT'
  143. 'SETSTROKEWEIGHT 0.5pt STROKENUMBER 0 OBJECT'
  144. 'SETSTROKEJOIN MITER 11° STROKENUMBER 0 OBJECT'
  145. 'SETSTROKEBEGIN FLAT STROKENUMBER 0 OBJECT'
  146. 'SETSTROKEEND FLAT STROKENUMBER 0 OBJECT'
  147. 'SETSTROKECAP BUTT STROKENUMBER 0 OBJECT'
  148. 'SETFILL BASIC STROKENUMBER 0 OBJECT'
  149. 'SETFPATTERN NONE STROKENUMBER 0 OBJECT'
  150. 'SETCOLORCOUNT 1 STROKENUMBER 0 OBJECT'
  151. 'SETCOLORSTYLE Black COLORNUMBER 0 STROKENUMBER 0 OBJECT'
  152. 'SETCOLORTINT 100% COLORNUMBER 0 STROKENUMBER 0 OBJECT'
  153. */
  154.  
  155. /* CD Cover */
  156.  
  157. x1       = cover_x1
  158. y1       = cover_y1
  159. x2       = cover_x2
  160. y2       = cover_y2
  161. cd_space = cover_space
  162.  
  163. 'DRAWBOX 'x1'mm 'y1'mm 'x2'mm 'y2'mm NORMAL'
  164.  
  165. test = set_busy(7)
  166.  
  167. IF test=1 THEN
  168.     CALL clean_up
  169.  
  170. /* CD Cover Text */
  171.  
  172. 'DRAWTEXTOBJ 'x1 + cd_space'mm 'y1 + cd_space'mm INFRONT'
  173.  
  174. txtid = RESULT
  175.  
  176. 'SELECTTEXT AT 'x1 + cd_space'mm 'y1 + cd_space'mm FRONTMOST'
  177.  
  178. 'SETALIGNMENT CENTER'
  179. 'SETBOLD OFF'
  180.  
  181. main_composer = replace_text(composer)
  182.  
  183. CALL print_text(main_composer)
  184.  
  185. 'INSERT ":"'
  186. 'INSERTCONTROL NEWLINE'
  187.  
  188. 'SETBOLD ON'
  189.  
  190. main_titel = replace_text(titel)
  191.  
  192. CALL print_text(main_titel)
  193.  
  194. /* 2x sonst macht es Pagestream nicht richtig...!!! */
  195. /* Das Objekt wird beim ersten mal zu klein Resized */
  196.  
  197. 'EDITTEXTOBJ POSITION 'x1 + cd_space'mm 'y1 + cd_space'mm 'x2 - cd_space'mm 'y2 - cd_space'mm OBJECTID 'txtid
  198. 'EDITTEXTOBJ POSITION 'x1 + cd_space'mm 'y1 + cd_space'mm 'x2 - cd_space'mm 'y2 - cd_space'mm OBJECTID 'txtid
  199.  
  200. test = set_busy(14)
  201.  
  202. IF test = 1 THEN
  203.     CALL clean_up
  204.  
  205. /* CD Inlay Left Side */
  206.  
  207. x1        = inlay_left_x1
  208. y1        = inlay_left_y1
  209. x2        = inlay_left_x2
  210. y2        = inlay_left_y2
  211. cd_space  = inlay_side_space
  212. cd_top    = inlay_side_top
  213. cd_length = inlay_side_length
  214. cd_width  = inlay_side_width
  215.  
  216. 'DRAWBOX 'x1'mm 'y1'mm 'x2'mm 'y2'mm NORMAL'
  217.  
  218. test = set_busy(21)
  219.  
  220. IF test = 1 THEN
  221.     CALL clean_up
  222.  
  223. /* CD Inlay Left Side Text */
  224.  
  225. 'DRAWTEXTOBJ 'x1 + cd_space'mm 'y2 - cd_top'mm INFRONT'
  226.  
  227. txtid = RESULT
  228.  
  229. 'SELECTTEXT AT 'x1 + cd_space'mm 'y2 - cd_top'mm FRONTMOST'
  230.  
  231. 'SETBOLD ON'
  232. 'INSERT "'composer' - "'
  233. 'SETBOLD OFF'
  234. 'INSERT "'titel'"'
  235.  
  236. 'EDITTEXTOBJ POSITION 'x1 + cd_space'mm 'y2 - cd_top'mm 'x1 + cd_length'mm 'y2 - cd_top + cd_width - 2 * cd_space'mm ROTATE 90° ABOUT 'x1 + cd_space'mm 'y2 - cd_top'mm OBJECTID 'txtid
  237.  
  238. test = set_busy(29)
  239.  
  240. IF test = 1 THEN
  241.     CALL clean_up
  242.  
  243. /* CD Inlay Right Side */
  244.  
  245. x1     = inlay_right_x1
  246. y1     = inlay_right_y1
  247. x2     = inlay_right_x2
  248. y2     = inlay_right_y2
  249.  
  250. 'DRAWBOX 'x1'mm 'y1'mm 'x2'mm 'y2'mm NORMAL'
  251.  
  252. test = set_busy(36)
  253.  
  254. IF test = 1 THEN
  255.     CALL clean_up
  256.  
  257. /* CD Inlay Right Side Text */
  258.  
  259. 'DRAWTEXTOBJ 'x2 - cd_space'mm 'y1 + cd_top'mm INFRONT'
  260.  
  261. txtid = RESULT
  262.  
  263. 'SELECTTEXT AT 'x2 - cd_space'mm 'y1 + cd_top'mm FRONTMOST'
  264.  
  265. 'SETBOLD ON'
  266. 'INSERT "'composer' - "'
  267. 'SETBOLD OFF'
  268. 'INSERT "'titel'"'
  269.  
  270. 'EDITTEXTOBJ POSITION 'x2 - cd_space'mm 'y1 + cd_top'mm 'x2 - cd_length'mm 'y1 + cd_top - cd_width + 2 * cd_space'mm ROTATE -90° ABOUT 'x2 - cd_space'mm 'y1 + cd_top'mm OBJECTID 'txtid
  271.  
  272. test = set_busy(43)
  273.  
  274. IF test = 1 THEN
  275.     CALL clean_up
  276.  
  277. /* CD Inlay Middle */
  278.  
  279. x1        = inlay_middle_x1
  280. y1      = inlay_middle_y1
  281. x2      = inlay_middle_x2
  282. y2      = inlay_middle_y2
  283. cd_space  = inlay_middle_space
  284.  
  285. 'DRAWBOX 'x1'mm 'y1'mm 'x2'mm 'y2'mm NORMAL'
  286.  
  287. test = set_busy(50)
  288.  
  289. IF test = 1 THEN
  290.     CALL clean_up
  291.  
  292. /* CD Inylay Text */
  293.  
  294. 'DRAWTEXTOBJ 'x1 + cd_space'mm 'y1 + cd_space'mm INFRONT'
  295.  
  296. txtid = RESULT
  297.  
  298. 'SELECTTEXT AT 'x1 + cd_space'mm 'y1 + cd_space'mm FRONTMOST'
  299. 'SETBOLD OFF'
  300. 'INSERT "'composer' - "'
  301. 'SETBOLD ON'
  302. 'INSERT "'titel'"'
  303. 'EDITTEXTOBJ POSITION 'x1 + cd_space'mm 'y1 + cd_space'mm 'x2 - cd_space'mm 'y1 + 2 * cd_space'mm OBJECTID 'txtid
  304.  
  305. prozentadd = 25 / anzahl_tno
  306. prozent = prozentadd + 50
  307.  
  308. max_fontwidth = 0
  309.  
  310. /* Loop Tracks */
  311.  
  312. DO i = 1 TO anzahl_tno
  313.  
  314.     /* Write TNO # */
  315.  
  316.     'DRAWTEXTOBJ 'x1 + cd_space'mm 'tno_start_y'mm INFRONT'
  317.  
  318.     txtid = RESULT
  319.  
  320.     'SELECTTEXT AT 'x1 + cd_space'mm 'tno_start_y'mm FRONTMOST'
  321.     'SETALIGNMENT CENTER'
  322.     'INSERT " 'i' "'
  323.     'STROKED ON OBJECTID 'txtid
  324.  
  325.     IF tno_heigth > 4 THEN
  326.         'EDITTEXTOBJ POSITION 'x1 + cd_space'mm 'tno_start_y'mm 'tno_start_x + 5'mm 'tno_start_y + tno_heigth - 2'mm OBJECTID 'txtid
  327.     ELSE
  328.         'EDITTEXTOBJ POSITION 'x1 + cd_space + 10'mm 'tno_start_y'mm 'x1 + cd_space + 15'mm 'tno_start_y + tno_heigth - 2'mm OBJECTID 'txtid
  329.  
  330.     /* Write TNO Titel */
  331.  
  332.         len = (LENGTH(tno_titel.i) * 94) / max_len
  333.  
  334.     'DRAWTEXTOBJ 'tno_start_x + 10'mm 'tno_start_y'mm INFRONT'
  335.  
  336.     txtid = RESULT
  337.  
  338.     'SELECTTEXT AT 'tno_start_x + 10'mm 'tno_start_y'mm FRONTMOST'
  339.     'INSERT "'tno_titel.i'"'
  340.  
  341.         'GETTEXTOBJ POSITION txtpos OBJECTID 'txtid
  342.  
  343.     txtheight1 = txtpos.bottom - txtpos.top
  344.     txtwidth1  = txtpos.right - txtpos.left
  345.  
  346.     'EDITTEXTOBJ POSITION 'tno_start_x +  10'mm 'tno_start_y'mm 'tno_start_x + len'mm 'tno_start_y + tno_heigth - 2'mm OBJECTID 'txtid
  347.  
  348.     IF len = 94 THEN DO
  349.  
  350.         /* Get max fontwidth */
  351.  
  352.             'GETTEXTOBJ POSITION txtpos OBJECTID 'txtid
  353.  
  354.         txtheight2 = txtpos.bottom - txtpos.top
  355.         txtwidth2  = txtpos.right - txtpos.left
  356.  
  357.         fontwidth = (98 * txtheight1 * txtwidth2) / (txtheight2 * txtwidth1)
  358.  
  359.         IF fontwidht > max_fontwidth THEN
  360.             max_fontwidth = fontwidth
  361.     END
  362.  
  363.     /* Write TNO Time */
  364.  
  365.     'DRAWTEXTOBJ 'tno_start_x + 100'mm 'tno_start_y'mm INFRONT'
  366.  
  367.     txtid = RESULT
  368.  
  369.     'SELECTTEXT AT 'tno_start_x + 100'mm 'tno_start_y'mm FRONTMOST'
  370.     'INSERT "'tno_time.i'"'
  371.     'EDITTEXTOBJ POSITION 'tno_start_x +  100'mm 'tno_start_y'mm 'tno_start_x + 115'mm 'tno_start_y + tno_heigth - 2'mm OBJECTID 'txtid
  372.  
  373.     tno_start_y = tno_start_y + tno_heigth
  374.  
  375.     test = set_busy(prozent)
  376.  
  377.     IF test = 1 THEN
  378.         CALL clean_up
  379.  
  380.     prozent = prozent + prozentadd
  381. END
  382.  
  383. /* Set same fontwidth */
  384.  
  385. tno_start_y = 161.4
  386.  
  387. DO i = 1 TO anzahl_tno
  388.  
  389.     'SELECTTEXT AT 'tno_start_x + 10'mm 'tno_start_y'mm FRONTMOST'
  390.     'SELECTTEXT ALL'
  391.  
  392.     IF max_fontwidth > 0 THEN
  393.         'SETTYPEWIDTH 'fontwidth''
  394.  
  395.     tno_start_y = tno_start_y + tno_heigth
  396.  
  397.     test = set_busy(prozent)
  398.  
  399.     IF test = 1 THEN
  400.         CALL clean_up
  401.  
  402.     prozent = prozent + prozentadd
  403. END
  404.  
  405. set_busy(100)
  406.  
  407. 'REFRESH ON'
  408. 'REFRESHWINDOW'
  409.  
  410. 'CLOSEBUSYREQUESTER 'busyreq''
  411. /*
  412. 'CLOSEWINDOW "View 1" PAGE 1'
  413. */
  414.  
  415. CLOSE(infile)
  416. RETURN 0
  417.  
  418. /* Replace Text */
  419.  
  420. replace_text:
  421.  
  422. text      = ARG(1)
  423. testindex = 0
  424.  
  425. DO WHILE POS(',', text, testindex + 1) > testindex
  426.  
  427.     testindexold = POS(',', text, testindex + 1)
  428.  
  429.     text         = DELSTR(text, testindexold, 1)
  430.     text         = INSERT('\n', text, testindexold - 1)
  431.     testindex    = testindexold + 2
  432. END
  433.  
  434. testindex = 0
  435.  
  436. DO WHILE POS('(', text, testindex + 1) > testindex
  437.  
  438.     testindexold = POS('(', text, testindex + 1)
  439.  
  440.     text         = INSERT('\n', text, testindexold - 1)
  441.     testindex    = testindexold + 2
  442. END
  443.  
  444. testindex = 0
  445.  
  446. DO WHILE POS('/', text, testindex + 1) > testindex
  447.  
  448.     testindexold = POS('/', text, testindex + 1)
  449.  
  450.     text         = DELSTR(text, testindexold, 1)
  451.     text         = INSERT('\n', text, testindexold - 1)
  452.     testindex    = testindexold + 2
  453. END
  454.  
  455. testindex = 0
  456.  
  457. DO WHILE POS('"', text, testindex + 1) > testindex
  458.  
  459.     testindexold = POS('"', text, testindex + 1)
  460.  
  461.     text         = DELSTR(text, testindexold, 1)
  462.     text         = INSERT('''', text, testindexold - 1)
  463.     testindex    = testindexold + 1
  464. END
  465.  
  466. RETURN text
  467.  
  468. /* Replace Quot */
  469.  
  470. replace_quot:
  471.  
  472. text      = ARG(1)
  473. testindex = 0
  474.  
  475. testindex = 0
  476.  
  477. DO WHILE POS('"', text, testindex + 1) > testindex
  478.  
  479.     testindexold = POS('"', text, testindex + 1)
  480.     text         = DELSTR(text, testindexold, 1)
  481.     text         = INSERT('''', text, testindexold - 1)
  482.     testindex    = testindexold + 1
  483. END
  484.  
  485. RETURN text
  486.  
  487. /* Print Text */
  488.  
  489. print_text:
  490.  
  491. text      = ARG(1)
  492. testindex = 0
  493.  
  494. DO WHILE POS('\n', text, testindex + 1) > testindex
  495.  
  496.     testindexold = POS('\n', text, testindex + 1)
  497.  
  498.     p_text       = STRIP(SUBSTR(text, 1, testindexold - 1))
  499.     text         = DELSTR(text, 1, testindexold + 1)
  500.  
  501.     'INSERT "'p_text'"'
  502.     'INSERTCONTROL NEWLINE'
  503.  
  504.     testindex = testindexold + 2
  505. END
  506.  
  507. 'INSERT "'text'"'
  508.  
  509. RETURN
  510.  
  511. /* Set Busy */
  512.  
  513. set_busy:
  514.  
  515. value = ARG(1)
  516.  
  517. 'SETBUSYREQUESTER 'busyreq' CURRENT 'value''
  518. 'GETBUSYREQUESTER 'busyreq''
  519.  
  520. RETURN RESULT
  521.  
  522. /* Clean Up */
  523.  
  524. clean_up:
  525.  
  526. 'CLOSEBUSYREQUESTER 'busyreq''
  527. /*
  528. 'CLOSEWINDOW "View 1" PAGE 1'
  529. */
  530.  
  531. CLOSE(infile)
  532.  
  533. EXIT
  534.